#pragma once

#include <vector>

using namespace std;

class ColorGroup {
public:
    vector<unsigned char[4]> color;
};

class MyColor
{
public:
    MyColor() { R = G = B = H = S = V = 0; }
    MyColor(unsigned char R, unsigned char G, unsigned char B) { this->R = R, this->G = G, this->B = B; H = S = V = 0; }

    unsigned char R, G, B;
    float H, S, V;
};

class MYRECT {
public:
    MYRECT() {
        left = top = right = botton = 0;
        R = 0, G = 0, B = 0, A = 0;
    }

    int left;
    int top;
    int right;
    int botton;

    unsigned char R, G, B, A;
};

MYRECT interception(unsigned char *colorBuff, int width, int height, int bit, unsigned char **buff);

void GetColorGropt(unsigned char *colorBuff, int width, int height, int bit);

void rotating(unsigned char *colorBuff, int width, int height, int bit, int r90);

void division(unsigned char *colorBuff, int width, int height, int bit);

void Linear(unsigned char *colorBuff, int width, int height, int bit);

vector<MYRECT *> *Tag(unsigned char *colorBuff, int width, int height, int bit);

unsigned char * getColor(unsigned char R, unsigned char G, unsigned char B);
void HSV_RGB(float h, float s, float v, unsigned char & R, unsigned char & G, unsigned char & B);

inline float Min(float a, float b) { return (a < b) ? a : b; }
inline float Max(float a, float b) { return (a > b) ? a : b; }
void RGB_HSV(unsigned char R, unsigned char G, unsigned char B, float &H, float &S, float &V);


void EdgeDetection(unsigned char * buff, int width, int height, int bit, unsigned char * mask, int lineWidth, int sc);

void EdgeDetectionRGB(unsigned char * buff, int width, int height, int bit, unsigned char * mask, int lineWidth, int sc);

void EdgeDetectionRGB_C(unsigned char * buff, int width, int height, int bit, unsigned char * mask, int lineWidth, int sc);

void Center_HSV(unsigned char * buff, int width, int height, int bit, int wid, float * h, float * s, float * v);

vector<MyColor> * get_color(unsigned char * buff, int width, int height, int bit, unsigned char * outBuff);

extern vector<MyColor> colors;
extern vector<MyColor> color9;